package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AqtoolsWorkerInfo;
import com.ruoyi.system.service.IAqtoolsWorkerInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工信息维护Controller
 * 
 * @author ye_wj
 * @date 2025-07-31
 */
@Controller
@RequestMapping("/system/info")
public class AqtoolsWorkerInfoController extends BaseController
{
    private String prefix = "system/info";

    @Autowired
    private IAqtoolsWorkerInfoService aqtoolsWorkerInfoService;

    @RequiresPermissions("system:info:view")
    @GetMapping()
    public String info()
    {
        return prefix + "/info";
    }

    /**
     * 查询员工信息维护列表
     */
    @RequiresPermissions("system:info:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AqtoolsWorkerInfo aqtoolsWorkerInfo)
    {
        startPage();
        List<AqtoolsWorkerInfo> list = aqtoolsWorkerInfoService.selectAqtoolsWorkerInfoList(aqtoolsWorkerInfo);
        return getDataTable(list);
    }

    /**
     * 导出员工信息维护列表
     */
    @RequiresPermissions("system:info:export")
    @Log(title = "员工信息维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AqtoolsWorkerInfo aqtoolsWorkerInfo)
    {
        List<AqtoolsWorkerInfo> list = aqtoolsWorkerInfoService.selectAqtoolsWorkerInfoList(aqtoolsWorkerInfo);
        ExcelUtil<AqtoolsWorkerInfo> util = new ExcelUtil<AqtoolsWorkerInfo>(AqtoolsWorkerInfo.class);
        return util.exportExcel(list, "员工信息维护数据");
    }

    /**
     * 新增员工信息维护
     */
    @RequiresPermissions("system:info:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存员工信息维护
     */
    @RequiresPermissions("system:info:add")
    @Log(title = "员工信息维护", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AqtoolsWorkerInfo aqtoolsWorkerInfo)
    {
        return toAjax(aqtoolsWorkerInfoService.insertAqtoolsWorkerInfo(aqtoolsWorkerInfo));
    }

    /**
     * 修改员工信息维护
     */
    @RequiresPermissions("system:info:edit")
    @GetMapping("/edit/{factory}")
    public String edit(@PathVariable("factory") String factory, ModelMap mmap)
    {
        AqtoolsWorkerInfo aqtoolsWorkerInfo = aqtoolsWorkerInfoService.selectAqtoolsWorkerInfoByFactory(factory);
        mmap.put("aqtoolsWorkerInfo", aqtoolsWorkerInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存员工信息维护
     */
    @RequiresPermissions("system:info:edit")
    @Log(title = "员工信息维护", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AqtoolsWorkerInfo aqtoolsWorkerInfo)
    {
        return toAjax(aqtoolsWorkerInfoService.updateAqtoolsWorkerInfo(aqtoolsWorkerInfo));
    }

    /**
     * 删除员工信息维护
     */
    @RequiresPermissions("system:info:remove")
    @Log(title = "员工信息维护", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aqtoolsWorkerInfoService.deleteAqtoolsWorkerInfoByFactorys(ids));
    }
}
